/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package bookingsystem;

import java.io.IOException;
import java.net.ConnectException;
import java.net.Socket;
import java.util.ArrayList;
import javax.swing.JOptionPane;

/**
 *
 * @author admin
 */
public class Client {
    public static void main(String[] args) {
        Socket client = null;
        int port = 7777;
        ArrayList reservations = new ArrayList(); 
        String reservationId = "AA1000001";
        String origin = "City";
        String destination = "Camp";
        String flightDate = "2011-11-21 12:00:00";
        String date = flightDate.substring(0, 10);
        String time = flightDate.substring(11, 16);
        int flightNo = 3;
        String bookingDate = "2011-11-09 08:32:25";
        String custName = "Pawel";
        String custLastName = "Idziak";
        String status = "Awaiting";
        reservations.add(new Reservation(reservationId,flightNo,custName,custLastName,origin,destination,date,time,bookingDate,status));
        reservationId = "AA1000002";
        origin = "Camp";
        destination = "City";
        flightDate = "2011-11-22 14:00:00";
        date = flightDate.substring(0, 10);
        time = flightDate.substring(11, 16);
        flightNo = 4;
        bookingDate = "2011-11-09 08:33:22";
        custName = "Paul";
        custLastName = "Smith";
        status = "Awaiting";
        reservations.add(new Reservation(reservationId,flightNo,custName,custLastName,origin,destination,date,time,bookingDate,status));
        
        try {
            client = new Socket("192.168.1.22", port);

            ClientThread ct;
            //ct = new ClientThread(client,oos,reservations);
            //Thread t = new Thread(ct);
            //t.start();
            //while(true){
           //     t.sleep(4000);
            //}
        } 
        catch (ConnectException e) {
            JOptionPane.showMessageDialog(null, "Cannot connect to the server", "Connection Error", 0);
        }
        catch (IOException e) {
            //System.out.println(e);
            e.printStackTrace();
       // } catch (InterruptedException ie){
         //       System.out.println(ie);
        }
    }
    
}
